﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
namespace String.Roman
{
    class Program
    {

        static void Main(string[] args)
        {
           
            AddRandomEmail();
         
            Console.ReadLine();
        }

       
        
        
        
        
        
        static void AddRandomEmail()
    {
  
      Console.WriteLine("Введите длинну первой части эмейла");
            int lenghtOfEmail = ReadIntFromConsole();
            Console.WriteLine("Введите количество адресов");
            int numberOfEmails = ReadIntFromConsole();
     

      Console.Clear();
      for (int i = 0; i < numberOfEmails; i++)
      {
          string first = FirstPartOfEmail(lenghtOfEmail);
          string mail = ChoiseMailBoxes();
          string s = "@";
          StringBuilder a = new StringBuilder(first);
          a.Append(s);
          a.Append(mail);


         // Console.WriteLine("{0}{1}{2}", first, s, mail);
          Console.WriteLine(a);
      }


    }
       
        
        
        
        
        
        
        static string FirstPartOfEmail(int lenghtOfEmeil)
        {
            char[] alphabet;
            alphabet = new char[]{'a','b','c', 'd','e','f','g','h','i','j','k','l','m','n','o','p','r','s','t','u','v','w','x','y','z'};
            char[] randomChosen = new char[lenghtOfEmeil];
            Random rand = new Random();
            for(int i = 0; i<lenghtOfEmeil; i++)
           {
                
               for (int j = 0; j < alphabet.Length; j++)
               {
                  char a = alphabet[rand.Next(0, alphabet.Length)];
                  Thread.Sleep(1);
                  randomChosen[i] = a;
                 
               }
           
                
               
           }
            string str = new string(randomChosen);
            return str;
        }

        static string ChoiseMailBoxes()
        {
      
            string[] mailBoxes = new string[]{"mail.ru","yandex.com","gmail.com","meta.ua"};
            Random rand = new Random();
            string mail = mailBoxes[rand.Next(0, mailBoxes.Length)];
          //  Console.WriteLine("{0}", mail);
            
            return mail;
        }
       
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        static int ReadIntFromConsole()
        {
            {
                int a = 0;
                bool inputsuccess = false;
                while (!inputsuccess)
                {
                    try
                    {
                        Console.WriteLine("");
                        string number = Console.ReadLine();
                        a = Int32.Parse(number);
                        inputsuccess = true;
                    }
                    catch
                    {
                        Console.WriteLine("Вы ввели некоректное значение");
                    }
                }
                return a;
            }
        }
        static string GetStringFromConsole()
        {
            Console.WriteLine("Введите строку для сортировки:");
            string stringFromConsole = Console.ReadLine();
            return stringFromConsole;
        }
        static void SplitStringToWords(string stringFromConsole)
        {
            string[] separators = { ",", ".", "!", "?", ";", ":", " " };
           /// string someString = "Строки-разделители: не включаются ! ,в набор элементов возвращаемого массива. ";
            string someString = stringFromConsole;
            string[] split = someString.Split(separators, StringSplitOptions.RemoveEmptyEntries);
            Array.Sort(split);
            PrintArray(split);
            Console.ReadKey();
        }
        static void PrintArray(string[] array)
        {
            for (int i = 0; i < array.Length; i++)
            {
                Console.Write(" - {0}", array[i]);
            }
        }
        static void PrintCharArray(char[] array)
        {
            for (int i = 0; i < array.Length; i++)
            {
                Console.Write("{0}", array[i]);
            }
        }

            /*  static void Main(string[] args)
              {
                  int[] array = GetUnique();
                  int[] arraySort = BubbleSort(array);
                  PrintArray(array);
                  Console.ReadKey();
              }



              static int[] GetUnique()
              {
                  int[] array = CreateRandomArray(100, 0, 100);
                  PrintArray(array);
                  int[] newArray = new int[array.Length];
                  int resIndex = 0;
                  for (int i = 0; i < array.Length; i++)
                  {
                      bool isunique = true;
                      for (int j = 0; j < array.Length; j++)
                      {
                         // bool isunique = true;
                          if (i == j)
                              continue;
                   
                          if(array[i] == array[j])
                           {
                               isunique = false;
                               break;
                           }

                      }
                      if (isunique)
                      {
                          newArray[resIndex++] = array[i];
                      }
                  }
                      return newArray;
              }





              static int[] CreateRandomArray(int lenght, int min, int max)
              {
                  int[] array = new int[lenght];
                  Random r = new Random();
                  for (int i = 0; i < array.Length; i++)
                  {
                      array[i] = r.Next(min, max);

                  }
                  // PrintArray(array);
                  return array;


              }
              static void PrintArray(int[] array)
              {
                  for (int i = 0; i < array.Length; i++)
                  {
                      Console.Write("{0} |", array[i]);
                  }
              }
              static int[] BubbleSort(int[] A)
              {

                  DateTime a = DateTime.Now;
                  int temp;

                  for (int i = 0; i < A.Length - 1; i++)
                  {
                      for (int j = 0; j < A.Length - i - 1; j++)
                      {
                          if (A[j] > A[j + 1])
                          {
                              temp = A[j];
                              A[j] = A[j + 1];
                              A[j + 1] = temp;
                          }


                      }
                  }
                  TimeSpan time = DateTime.Now - a;
                  Console.Clear();
                  Console.WriteLine("Время сортировки составило:  {0} милисекунд", time.TotalMilliseconds);

                  return A;
              }*/

        
    }
}